package monitorAction;

import monitor.Monitor;
import monitorDao.MonitorDao;

import com.opensymphony.xwork2.ActionSupport;

public class MonitorAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Long id;

	private Monitor monitor;

	private MonitorDao monitorDao;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Monitor getMonitor() {
		return monitor;
	}

	public void setMonitor(Monitor monitor) {
		this.monitor = monitor;
	}

	public MonitorDao getMonitorDao() {
		return monitorDao;
	}

	public void setMonitorDao(MonitorDao monitorDao) {
		this.monitorDao = monitorDao;
	}

	public String create() {
		return SUCCESS;
	}

	public String delete() {
		return SUCCESS;
	}

	public String updateProjector() {
		Monitor temp = monitorDao.selectAll();
		monitor.setId(temp.getId());
		monitor.setExpansibility(temp.getExpansibility());
		monitor.setIntroduction(temp.getIntroduction());
		monitor.setPragmatism(temp.getPragmatism());
		monitor.setSurvey(temp.getSurvey());
		monitorDao.update(monitor);
		return SUCCESS;
	}

	public String updateSurvey() {
		monitorDao.saveOrUpdate(monitor);
		return SUCCESS;
	}

	public String updatePragmatism() {
		Monitor temp = monitorDao.selectAll();
		monitor.setId(temp.getId());
		monitor.setExpansibility(temp.getExpansibility());
		monitor.setIntroduction(temp.getIntroduction());
		monitor.setProjector(temp.getProjector());
		monitor.setSurvey(temp.getSurvey());
		monitorDao.update(monitor);
		return SUCCESS;
	}

	public String updateIntro() {
		Monitor temp = monitorDao.selectAll();
		monitor.setId(temp.getId());
		monitor.setExpansibility(temp.getExpansibility());
		monitor.setProjector(temp.getProjector());
		monitor.setSurvey(temp.getSurvey());
		monitor.setPragmatism(temp.getPragmatism());
		monitorDao.update(monitor);
		return SUCCESS;
	}

	public String updateExpansibility() {
		Monitor temp = monitorDao.selectAll();
		monitor.setId(temp.getId());
		monitor.setIntroduction(temp.getIntroduction());
		monitor.setProjector(temp.getProjector());
		monitor.setSurvey(temp.getSurvey());
		monitor.setPragmatism(temp.getPragmatism());
		monitorDao.update(monitor);
		return SUCCESS;
	}

	public String select() {
		monitor = monitorDao.selectAll();
		return SUCCESS;
	}
}
